/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package univalle.eisc.pais.ai.searcheslab.view;

import java.io.IOException;
import java.io.OutputStream;
import javax.swing.JTextArea;
import javax.swing.JTextPane;

/**
 *
 * @author vivancu
 */
public class JTextPaneOutputStream extends OutputStream {

    private JTextPane textPane;

    public JTextPaneOutputStream(JTextPane TextPane) {
        this.textPane = TextPane;
    }

    @Override
    public void write(int b) throws IOException {
        // redirects data to the text area
        textPane.setText(textPane.getText() + String.valueOf((char) b));
        // scrolls the text area to the end of data
        textPane.setCaretPosition(textPane.getDocument().getLength());
    }
}